package controller;

import interfaces.MainFrame;

import java.rmi.RemoteException;
import java.util.List;

import model.AlarmClockWrapper;
import model.AlarmTypeWrapper;
import services.AlarmClock;
import services.AlarmType;
import services.UserDataServicesProxy;

import com.google.common.collect.Lists;

public class AlarmClockController {

	private List<AlarmTypeWrapper> types = Lists.newArrayList();
	private List<AlarmClockWrapper> clocks = Lists.newArrayList();
	public AlarmClockController() {
		try {
			Object[] alarmTypes = new UserDataServicesProxy().getAlarmTypes();
			for(Object obj : alarmTypes) {
				AlarmType type = (AlarmType) obj;
				types.add(AlarmTypeWrapper.wrap(type));
			}
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		try {
			Object[] alarmclocks = new UserDataServicesProxy().getAlarmClocks(MainFrame.getUser());
			for(Object obj : alarmclocks) {
				AlarmClock type = (AlarmClock) obj;
				clocks.add(AlarmClockWrapper.wrap(type));
			}
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}
	
	
	public List<AlarmClockWrapper> getData() {
		return clocks;
	}
	public List<AlarmTypeWrapper> getTypes() {
		return types;
	}
}
